function setcont(hfile, bc)
% BVQXfile::setcont  - override entire contents of object
%
% FORMAT:       setcont(obj, content)
%
% Input fields:
%
%       obj         non-ROOT BVQXfile object
%       content     1x1 content struct
%
% No output fields.

% Version:  v0.7b
% Build:    7082922
% Date:     Aug-29 2006, 10:29 PM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin ~= 2 || ...
    numel(hfile) ~= 1 || ...
    numel(bc) ~= 1 || ...
   ~isBVQXfile(hfile, true) || ...
    hfile.L == 1
    error( ...
        'BVQXfile:BadArgument', ...
        'Invalid object for assignment.' ...
    );
end

% get content first
cc = bvqxfile_getcont(hfile.L);
if numel(fieldnames(cc)) ~= numel(fieldnames(bc)) || ...
   ~all(strcmp(fieldnames(cc), fieldnames(cc)))
    error( ...
        'BVQXfile:BadArgument', ...
        'Mismatching fieldnames, content not set.' ...
    );
end

% assignment
try
    bvqxfile_setcont(hfile.L, bc);
catch
    rethrow(lasterror);
end
